import { parseHTML } from './parseAst'
import { generate } from './generate'

export function compilerToFunction(el) {
  // dom   ===> ast语法树
  let ast = parseHTML(el);
  // ast语法树 ===>  render函数
  let code = generate(ast);
  let render = new Function(`with(this){
    return ${code}
  }`);
  
  return render;
}